﻿namespace WinForms.ControlList.Sales
{
    using Bll.Comm;
    using Bll.Sales;
    using Bll.Systems;
    using Model.Comm;
    using Model.Sales;
    using Model.Systems;
    using PublicStaticClass;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Drawing.Printing;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    using WinForms;
    using WinForms.ControlList.Systems;
    using WinForms.Properties;

    public class FrmOrdersPrint : Form
    {
        private DataGridViewTextBoxColumn AllMoneys;
        private DataGridViewTextBoxColumn Amount;
        private DataGridViewTextBoxColumn AmountUnit;
        private DataGridViewTextBoxColumn AmoutMoney;
        private Button btn_Close;
        private Button btn_Print;
        private Button btn_PrintSet;
        private Button btn_PrintVeiw;
        private DataGridViewTextBoxColumn CommName;
        private DataGridViewTextBoxColumn CommType;
        private IContainer components = null;
        private DataGridView DataGridList;
        private DataGridViewTextBoxColumn Discount;
        private FormHelper fh = new FormHelper();
        public const int HTCAPTION = 2;
        private DataGridViewTextBoxColumn IsZs;
        private Label label1;
        private Label label2;
        private Label lbl_AllMoney;
        private Label lbl_AllMoneyTitle;
        private Label lbl_ChuNa;
        private Label lbl_CreateMan;
        private Label lbl_DateTime;
        private Label lbl_DaXie;
        private Label lbl_DaXieTitle;
        private Label lbl_GuestName;
        private Label lbl_KaiPiaoRen;
        private Label lbl_KuaiJi;
        private Label lbl_NoNum;
        private Label lbl_PrintAddress;
        private Label lbl_PrintTel;
        private Label lbl_PrintTiltes;
        private Label lbl_Titles;
        private Label lblTitle;
        private DataGridViewTextBoxColumn LotNum;
        private Bitmap memoryImage;
        private PrintDocument MyPrintDocument;
        private OrdersEnt order = null;
        private Panel pan_AllPanel;
        private Panel pan_AllPlanes;
        private Panel pan_Bottoms;
        private Panel pan_Dock;
        private Panel pan_DockBottom;
        private Panel pan_DockLeft;
        private Panel pan_DockRight;
        private Panel pan_Lefts;
        private Panel pan_Rights;
        private Panel pan_Top;
        private Panel pan_TopLeft;
        private Panel pan_TopRight;
        private Panel pan_ZhongJian;
        private Panel pane_TopT;
        private Panel panel_Button;
        private Panel panel_Title;
        private Panel panel1;
        private Panel panel10;
        private Panel panel2;
        private Panel panel3;
        private Panel panel4;
        private Panel panel5;
        private Panel panel6;
        private Panel panel7;
        private Panel panel8;
        private Panel panel9;
        private PrintDialog PrintDialogs = new PrintDialog();
        private DataGridViewTextBoxColumn Remark;
        private DataGridViewTextBoxColumn salescommid;
        public const int SC_MOVE = 0xf010;
        private DataGridViewTextBoxColumn StandardMoney;
        public const int WM_SYSCOMMAND = 0x112;

        public FrmOrdersPrint(int orderId)
        {
            this.InitializeComponent();
            this.order = OrdersBll.GetModel(orderId);
            UserEnt loginUser = PublicAppliction.LoginUser;
            ChainEnt model = ChainBll.GetModel(loginUser.ChainNum);
            this.lbl_PrintTiltes.Text = model.ChainName;
            this.lbl_PrintAddress.Text = "地址:" + model.ChainAdress;
            this.lbl_PrintTel.Text = "电话:" + model.ChainTel + "      传真:" + model.ChainFax;
            this.lbl_PrintTiltes.Location = new Point((this.panel_Title.Width - this.lbl_PrintTiltes.Width) / 2, this.lbl_PrintTiltes.Location.Y);
            this.lbl_PrintAddress.Location = new Point((this.panel_Title.Width - this.lbl_PrintAddress.Width) / 2, this.lbl_PrintAddress.Location.Y);
            this.lbl_PrintTel.Location = new Point((this.panel_Title.Width - this.lbl_PrintTel.Width) / 2, this.lbl_PrintTel.Location.Y);
            this.lbl_NoNum.Text = "No." + this.order.OrderNum;
            this.lbl_DateTime.Text = "日期:" + this.order.CreateTime.ToString("yyyy年MM月dd日");
            this.lbl_GuestName.Text = "客户:" + this.order.GuestName;
            this.LoadSalesDeticl(orderId);
            this.lbl_CreateMan.Text = loginUser.UserName;
            PrintSettingEnt ent3 = PrintSettingBll.GetModel(2);
            this.MyPrintDocument.DefaultPageSettings.Margins = new Margins(int.Parse(ent3.LeftMargin.ToString()), int.Parse(ent3.RightMargin.ToString()), int.Parse(ent3.TopMargin.ToString()), int.Parse(ent3.BottomMargin.ToString()));
        }

        [DllImport("gdi32.dll")]
        public static extern long BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
        private void btn_Close_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btn_Print_Click(object sender, EventArgs e)
        {
            this.CaptureScreen();
            if (this.PrintDialogs.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    this.MyPrintDocument.Print();
                }
                catch
                {
                }
                if (this.order != null)
                {
                    WorkLogBll.AddNewLog("打印销售订单:" + this.order.OrderNum, "", PublicAppliction.LoginUser);
                }
            }
        }

        private void btn_PrintSet_Click(object sender, EventArgs e)
        {
            FrmPrintSetting setting = new FrmPrintSetting();
            if (setting.ShowDialog() == DialogResult.OK)
            {
                PrintSettingEnt model = PrintSettingBll.GetModel(2);
                this.MyPrintDocument.DefaultPageSettings.Margins = new Margins(int.Parse(model.LeftMargin.ToString()), int.Parse(model.RightMargin.ToString()), int.Parse(model.TopMargin.ToString()), int.Parse(model.BottomMargin.ToString()));
            }
        }

        private void btn_PrintVeiw_Click(object sender, EventArgs e)
        {
            this.CaptureScreen();
            new PrintPreviewDialog { Document = this.MyPrintDocument }.ShowDialog();
        }

        private void CaptureScreen()
        {
            this.panel_Button.Visible = false;
            Graphics g = this.pan_AllPlanes.CreateGraphics();
            Size size = this.pan_AllPlanes.Size;
            this.memoryImage = new Bitmap(size.Width, size.Height, g);
            Graphics graphics2 = Graphics.FromImage(this.memoryImage);
            IntPtr hdc = g.GetHdc();
            IntPtr hdcDest = graphics2.GetHdc();
            BitBlt(hdcDest, 0, 0, this.pan_AllPlanes.ClientRectangle.Width, this.pan_AllPlanes.ClientRectangle.Height, hdc, 0, 0, 0xcc0020);
            g.ReleaseHdc(hdc);
            graphics2.ReleaseHdc(hdcDest);
            this.panel_Button.Visible = true;
        }

        private void DataGridList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            this.DataGridList.ClearSelection();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmOrdersPrint_Load(object sender, EventArgs e)
        {
            this.DataGridList.ClearSelection();
            this.MyPrintDocument.OriginAtMargins = true;
            this.btn_Print.Select();
        }

        private void InitializeComponent()
        {
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            DataGridViewCellStyle style2 = new DataGridViewCellStyle();
            DataGridViewCellStyle style3 = new DataGridViewCellStyle();
            DataGridViewCellStyle style4 = new DataGridViewCellStyle();
            DataGridViewCellStyle style5 = new DataGridViewCellStyle();
            DataGridViewCellStyle style6 = new DataGridViewCellStyle();
            DataGridViewCellStyle style7 = new DataGridViewCellStyle();
            DataGridViewCellStyle style8 = new DataGridViewCellStyle();
            DataGridViewCellStyle style9 = new DataGridViewCellStyle();
            DataGridViewCellStyle style10 = new DataGridViewCellStyle();
            this.pan_DockLeft = new Panel();
            this.pan_Dock = new Panel();
            this.pan_AllPanel = new Panel();
            this.panel_Button = new Panel();
            this.btn_PrintVeiw = new Button();
            this.btn_PrintSet = new Button();
            this.btn_Close = new Button();
            this.btn_Print = new Button();
            this.pan_AllPlanes = new Panel();
            this.panel4 = new Panel();
            this.lbl_CreateMan = new Label();
            this.lbl_KaiPiaoRen = new Label();
            this.lbl_ChuNa = new Label();
            this.lbl_KuaiJi = new Label();
            this.panel3 = new Panel();
            this.panel6 = new Panel();
            this.label2 = new Label();
            this.label1 = new Label();
            this.panel5 = new Panel();
            this.panel7 = new Panel();
            this.panel10 = new Panel();
            this.lbl_DaXie = new Label();
            this.lbl_DaXieTitle = new Label();
            this.panel8 = new Panel();
            this.lbl_AllMoney = new Label();
            this.lbl_AllMoneyTitle = new Label();
            this.DataGridList = new DataGridView();
            this.salescommid = new DataGridViewTextBoxColumn();
            this.LotNum = new DataGridViewTextBoxColumn();
            this.CommType = new DataGridViewTextBoxColumn();
            this.CommName = new DataGridViewTextBoxColumn();
            this.StandardMoney = new DataGridViewTextBoxColumn();
            this.Discount = new DataGridViewTextBoxColumn();
            this.AmoutMoney = new DataGridViewTextBoxColumn();
            this.Amount = new DataGridViewTextBoxColumn();
            this.AllMoneys = new DataGridViewTextBoxColumn();
            this.AmountUnit = new DataGridViewTextBoxColumn();
            this.Remark = new DataGridViewTextBoxColumn();
            this.IsZs = new DataGridViewTextBoxColumn();
            this.panel_Title = new Panel();
            this.panel2 = new Panel();
            this.lbl_NoNum = new Label();
            this.panel1 = new Panel();
            this.lbl_GuestName = new Label();
            this.lbl_DateTime = new Label();
            this.lbl_Titles = new Label();
            this.lbl_PrintTel = new Label();
            this.lbl_PrintAddress = new Label();
            this.lbl_PrintTiltes = new Label();
            this.panel9 = new Panel();
            this.pan_Rights = new Panel();
            this.pan_Lefts = new Panel();
            this.pan_Bottoms = new Panel();
            this.pane_TopT = new Panel();
            this.pan_DockBottom = new Panel();
            this.pan_DockRight = new Panel();
            this.pan_Top = new Panel();
            this.pan_ZhongJian = new Panel();
            this.lblTitle = new Label();
            this.pan_TopRight = new Panel();
            this.pan_TopLeft = new Panel();
            this.MyPrintDocument = new PrintDocument();
            this.pan_Dock.SuspendLayout();
            this.pan_AllPanel.SuspendLayout();
            this.panel_Button.SuspendLayout();
            this.pan_AllPlanes.SuspendLayout();
            this.panel4.SuspendLayout();
            this.panel3.SuspendLayout();
            this.panel6.SuspendLayout();
            this.panel5.SuspendLayout();
            this.panel7.SuspendLayout();
            this.panel10.SuspendLayout();
            this.panel8.SuspendLayout();
            ((ISupportInitialize) this.DataGridList).BeginInit();
            this.panel_Title.SuspendLayout();
            this.panel2.SuspendLayout();
            this.panel1.SuspendLayout();
            this.pan_Top.SuspendLayout();
            this.pan_ZhongJian.SuspendLayout();
            base.SuspendLayout();
            this.pan_DockLeft.BackColor = Color.FromArgb(0xaf, 0xbf, 190);
            this.pan_DockLeft.Dock = DockStyle.Left;
            this.pan_DockLeft.Location = new Point(0, 0);
            this.pan_DockLeft.Name = "pan_DockLeft";
            this.pan_DockLeft.Size = new Size(1, 0x1ed);
            this.pan_DockLeft.TabIndex = 0;
            this.pan_Dock.BackColor = Color.FromArgb(0, 0, 15, 0xff);
            this.pan_Dock.Controls.Add(this.pan_AllPanel);
            this.pan_Dock.Controls.Add(this.pan_DockBottom);
            this.pan_Dock.Controls.Add(this.pan_DockRight);
            this.pan_Dock.Controls.Add(this.pan_DockLeft);
            this.pan_Dock.Dock = DockStyle.Fill;
            this.pan_Dock.Location = new Point(0, 0x20);
            this.pan_Dock.Name = "pan_Dock";
            this.pan_Dock.Size = new Size(770, 0x1ed);
            this.pan_Dock.TabIndex = 5;
            this.pan_AllPanel.BackColor = Color.White;
            this.pan_AllPanel.Controls.Add(this.panel_Button);
            this.pan_AllPanel.Controls.Add(this.pan_AllPlanes);
            this.pan_AllPanel.Controls.Add(this.pan_Rights);
            this.pan_AllPanel.Controls.Add(this.pan_Lefts);
            this.pan_AllPanel.Controls.Add(this.pan_Bottoms);
            this.pan_AllPanel.Controls.Add(this.pane_TopT);
            this.pan_AllPanel.Dock = DockStyle.Fill;
            this.pan_AllPanel.Location = new Point(1, 0);
            this.pan_AllPanel.Name = "pan_AllPanel";
            this.pan_AllPanel.Size = new Size(0x300, 0x1ec);
            this.pan_AllPanel.TabIndex = 3;
            this.panel_Button.Controls.Add(this.btn_PrintVeiw);
            this.panel_Button.Controls.Add(this.btn_PrintSet);
            this.panel_Button.Controls.Add(this.btn_Close);
            this.panel_Button.Controls.Add(this.btn_Print);
            this.panel_Button.Dock = DockStyle.Fill;
            this.panel_Button.Location = new Point(10, 0x1bb);
            this.panel_Button.Name = "panel_Button";
            this.panel_Button.Size = new Size(0x2ec, 0x27);
            this.panel_Button.TabIndex = 10;
            this.btn_PrintVeiw.Location = new Point(0x120, 8);
            this.btn_PrintVeiw.Name = "btn_PrintVeiw";
            this.btn_PrintVeiw.Size = new Size(0x4b, 0x17);
            this.btn_PrintVeiw.TabIndex = 13;
            this.btn_PrintVeiw.Text = "打印预览";
            this.btn_PrintVeiw.UseVisualStyleBackColor = true;
            this.btn_PrintVeiw.Click += new EventHandler(this.btn_PrintVeiw_Click);
            this.btn_PrintSet.Location = new Point(0x182, 8);
            this.btn_PrintSet.Name = "btn_PrintSet";
            this.btn_PrintSet.Size = new Size(0x4b, 0x17);
            this.btn_PrintSet.TabIndex = 12;
            this.btn_PrintSet.Text = "打印设置";
            this.btn_PrintSet.UseVisualStyleBackColor = true;
            this.btn_PrintSet.Click += new EventHandler(this.btn_PrintSet_Click);
            this.btn_Close.Location = new Point(0x1e4, 8);
            this.btn_Close.Name = "btn_Close";
            this.btn_Close.Size = new Size(0x4b, 0x17);
            this.btn_Close.TabIndex = 11;
            this.btn_Close.Text = "关 闭";
            this.btn_Close.UseVisualStyleBackColor = true;
            this.btn_Close.Click += new EventHandler(this.btn_Close_Click);
            this.btn_Print.Location = new Point(190, 8);
            this.btn_Print.Name = "btn_Print";
            this.btn_Print.Size = new Size(0x4b, 0x17);
            this.btn_Print.TabIndex = 10;
            this.btn_Print.Text = "打 印";
            this.btn_Print.UseVisualStyleBackColor = true;
            this.btn_Print.Click += new EventHandler(this.btn_Print_Click);
            this.pan_AllPlanes.Controls.Add(this.panel4);
            this.pan_AllPlanes.Controls.Add(this.panel3);
            this.pan_AllPlanes.Controls.Add(this.panel_Title);
            this.pan_AllPlanes.Controls.Add(this.panel9);
            this.pan_AllPlanes.Dock = DockStyle.Top;
            this.pan_AllPlanes.Location = new Point(10, 10);
            this.pan_AllPlanes.Name = "pan_AllPlanes";
            this.pan_AllPlanes.Size = new Size(0x2ec, 0x1b1);
            this.pan_AllPlanes.TabIndex = 4;
            this.panel4.Controls.Add(this.lbl_CreateMan);
            this.panel4.Controls.Add(this.lbl_KaiPiaoRen);
            this.panel4.Controls.Add(this.lbl_ChuNa);
            this.panel4.Controls.Add(this.lbl_KuaiJi);
            this.panel4.Dock = DockStyle.Top;
            this.panel4.Location = new Point(0, 0x18e);
            this.panel4.Name = "panel4";
            this.panel4.Size = new Size(0x2ec, 0x19);
            this.panel4.TabIndex = 12;
            this.lbl_CreateMan.AutoSize = true;
            this.lbl_CreateMan.Location = new Point(0x255, 7);
            this.lbl_CreateMan.Name = "lbl_CreateMan";
            this.lbl_CreateMan.Size = new Size(0x29, 12);
            this.lbl_CreateMan.TabIndex = 3;
            this.lbl_CreateMan.Text = "label3";
            this.lbl_KaiPiaoRen.AutoSize = true;
            this.lbl_KaiPiaoRen.Location = new Point(0x220, 7);
            this.lbl_KaiPiaoRen.Name = "lbl_KaiPiaoRen";
            this.lbl_KaiPiaoRen.Size = new Size(0x2f, 12);
            this.lbl_KaiPiaoRen.TabIndex = 2;
            this.lbl_KaiPiaoRen.Text = "开票人:";
            this.lbl_ChuNa.AutoSize = true;
            this.lbl_ChuNa.Location = new Point(0x14f, 7);
            this.lbl_ChuNa.Name = "lbl_ChuNa";
            this.lbl_ChuNa.Size = new Size(0x23, 12);
            this.lbl_ChuNa.TabIndex = 1;
            this.lbl_ChuNa.Text = "出纳:";
            this.lbl_KuaiJi.AutoSize = true;
            this.lbl_KuaiJi.Location = new Point(0x60, 7);
            this.lbl_KuaiJi.Name = "lbl_KuaiJi";
            this.lbl_KuaiJi.Size = new Size(0x23, 12);
            this.lbl_KuaiJi.TabIndex = 0;
            this.lbl_KuaiJi.Text = "会计:";
            this.panel3.Controls.Add(this.panel6);
            this.panel3.Controls.Add(this.panel5);
            this.panel3.Dock = DockStyle.Top;
            this.panel3.Location = new Point(0, 0xa3);
            this.panel3.Name = "panel3";
            this.panel3.Size = new Size(0x2ec, 0xeb);
            this.panel3.TabIndex = 11;
            this.panel6.Controls.Add(this.label2);
            this.panel6.Controls.Add(this.label1);
            this.panel6.Dock = DockStyle.Right;
            this.panel6.Location = new Point(0x2d2, 0);
            this.panel6.Name = "panel6";
            this.panel6.Size = new Size(0x1a, 0xeb);
            this.panel6.TabIndex = 1;
            this.label2.AutoSize = true;
            this.label2.Location = new Point(5, 0x87);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x11, 0x30);
            this.label2.TabIndex = 1;
            this.label2.Text = "客\r\n户\r\n\r\n红";
            this.label1.AutoSize = true;
            this.label1.Location = new Point(5, 0x29);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x11, 0x30);
            this.label1.TabIndex = 0;
            this.label1.Text = "存\r\n根\r\n\r\n白";
            this.panel5.Controls.Add(this.panel7);
            this.panel5.Controls.Add(this.DataGridList);
            this.panel5.Dock = DockStyle.Left;
            this.panel5.Location = new Point(0, 0);
            this.panel5.Name = "panel5";
            this.panel5.Size = new Size(0x2cf, 0xeb);
            this.panel5.TabIndex = 0;
            this.panel7.Controls.Add(this.panel10);
            this.panel7.Controls.Add(this.panel8);
            this.panel7.Dock = DockStyle.Fill;
            this.panel7.Location = new Point(0, 0xd4);
            this.panel7.Name = "panel7";
            this.panel7.Size = new Size(0x2cf, 0x17);
            this.panel7.TabIndex = 20;
            this.panel10.Controls.Add(this.lbl_DaXie);
            this.panel10.Controls.Add(this.lbl_DaXieTitle);
            this.panel10.Dock = DockStyle.Fill;
            this.panel10.Location = new Point(0, 0);
            this.panel10.Name = "panel10";
            this.panel10.Size = new Size(0x1a5, 0x17);
            this.panel10.TabIndex = 5;
            this.panel10.Paint += new PaintEventHandler(this.panel10_Paint);
            this.lbl_DaXie.AutoSize = true;
            this.lbl_DaXie.Location = new Point(0x89, 5);
            this.lbl_DaXie.Name = "lbl_DaXie";
            this.lbl_DaXie.Size = new Size(0, 12);
            this.lbl_DaXie.TabIndex = 5;
            this.lbl_DaXieTitle.AutoSize = true;
            this.lbl_DaXieTitle.Location = new Point(0x60, 5);
            this.lbl_DaXieTitle.Name = "lbl_DaXieTitle";
            this.lbl_DaXieTitle.Size = new Size(0x23, 12);
            this.lbl_DaXieTitle.TabIndex = 4;
            this.lbl_DaXieTitle.Text = "大写:";
            this.panel8.Controls.Add(this.lbl_AllMoney);
            this.panel8.Controls.Add(this.lbl_AllMoneyTitle);
            this.panel8.Dock = DockStyle.Right;
            this.panel8.Location = new Point(0x1a5, 0);
            this.panel8.Name = "panel8";
            this.panel8.Size = new Size(0x12a, 0x17);
            this.panel8.TabIndex = 4;
            this.panel8.Paint += new PaintEventHandler(this.panel8_Paint);
            this.lbl_AllMoney.AutoSize = true;
            this.lbl_AllMoney.Location = new Point(0x3b, 5);
            this.lbl_AllMoney.Name = "lbl_AllMoney";
            this.lbl_AllMoney.Size = new Size(0, 12);
            this.lbl_AllMoney.TabIndex = 3;
            this.lbl_AllMoneyTitle.AutoSize = true;
            this.lbl_AllMoneyTitle.Location = new Point(0x11, 5);
            this.lbl_AllMoneyTitle.Name = "lbl_AllMoneyTitle";
            this.lbl_AllMoneyTitle.Size = new Size(0x23, 12);
            this.lbl_AllMoneyTitle.TabIndex = 2;
            this.lbl_AllMoneyTitle.Text = "合计:";
            this.DataGridList.AllowUserToAddRows = false;
            this.DataGridList.AllowUserToDeleteRows = false;
            this.DataGridList.AllowUserToResizeColumns = false;
            this.DataGridList.AllowUserToResizeRows = false;
            style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style.BackColor = Color.FromArgb(0xf9, 0xf9, 0xf9);
            this.DataGridList.AlternatingRowsDefaultCellStyle = style;
            this.DataGridList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            this.DataGridList.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
            this.DataGridList.BackgroundColor = Color.White;
            this.DataGridList.BorderStyle = BorderStyle.None;
            this.DataGridList.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
            style2.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style2.BackColor = Color.White;
            style2.Font = new Font("宋体", 9f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            style2.ForeColor = SystemColors.WindowText;
            style2.SelectionBackColor = SystemColors.Highlight;
            style2.SelectionForeColor = SystemColors.HighlightText;
            this.DataGridList.ColumnHeadersDefaultCellStyle = style2;
            this.DataGridList.Columns.AddRange(new DataGridViewColumn[] { this.salescommid, this.LotNum, this.CommType, this.CommName, this.StandardMoney, this.Discount, this.AmoutMoney, this.Amount, this.AllMoneys, this.AmountUnit, this.Remark, this.IsZs });
            style3.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style3.BackColor = SystemColors.Window;
            style3.Font = new Font("宋体", 9f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            style3.ForeColor = SystemColors.ControlText;
            style3.SelectionBackColor = SystemColors.Highlight;
            style3.SelectionForeColor = SystemColors.HighlightText;
            style3.WrapMode = DataGridViewTriState.False;
            this.DataGridList.DefaultCellStyle = style3;
            this.DataGridList.Dock = DockStyle.Top;
            this.DataGridList.EnableHeadersVisualStyles = false;
            this.DataGridList.GridColor = Color.Black;
            this.DataGridList.Location = new Point(0, 0);
            this.DataGridList.MultiSelect = false;
            this.DataGridList.Name = "DataGridList";
            this.DataGridList.ReadOnly = true;
            style4.Alignment = DataGridViewContentAlignment.BottomCenter;
            style4.BackColor = Color.White;
            style4.Font = new Font("宋体", 9f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            style4.ForeColor = SystemColors.WindowText;
            style4.SelectionBackColor = SystemColors.Highlight;
            style4.SelectionForeColor = SystemColors.HighlightText;
            this.DataGridList.RowHeadersDefaultCellStyle = style4;
            this.DataGridList.RowHeadersVisible = false;
            style5.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.DataGridList.RowsDefaultCellStyle = style5;
            this.DataGridList.RowTemplate.Height = 0x17;
            this.DataGridList.Size = new Size(0x2cf, 0xd4);
            this.DataGridList.TabIndex = 0x13;
            this.DataGridList.CellClick += new DataGridViewCellEventHandler(this.DataGridList_CellClick);
            this.salescommid.HeaderText = "salescommid";
            this.salescommid.Name = "salescommid";
            this.salescommid.ReadOnly = true;
            this.salescommid.Visible = false;
            this.salescommid.Width = 0x60;
            this.LotNum.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.LotNum.DataPropertyName = "LotNum";
            style6.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style6.BackColor = Color.White;
            this.LotNum.DefaultCellStyle = style6;
            this.LotNum.FillWeight = 150f;
            this.LotNum.HeaderText = "批号";
            this.LotNum.Name = "LotNum";
            this.LotNum.ReadOnly = true;
            this.CommType.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.CommType.DataPropertyName = "CommType";
            style7.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style7.BackColor = Color.White;
            this.CommType.DefaultCellStyle = style7;
            this.CommType.FillWeight = 150f;
            this.CommType.HeaderText = "商品类型";
            this.CommType.Name = "CommType";
            this.CommType.ReadOnly = true;
            this.CommName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.CommName.DataPropertyName = "CommName";
            style8.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style8.BackColor = Color.White;
            this.CommName.DefaultCellStyle = style8;
            this.CommName.FillWeight = 150f;
            this.CommName.HeaderText = "商品名称";
            this.CommName.Name = "CommName";
            this.CommName.ReadOnly = true;
            this.CommName.Resizable = DataGridViewTriState.True;
            this.StandardMoney.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.StandardMoney.HeaderText = "标准价";
            this.StandardMoney.Name = "StandardMoney";
            this.StandardMoney.ReadOnly = true;
            this.Discount.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.Discount.HeaderText = "折扣";
            this.Discount.Name = "Discount";
            this.Discount.ReadOnly = true;
            this.AmoutMoney.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.AmoutMoney.HeaderText = "折后价";
            this.AmoutMoney.Name = "AmoutMoney";
            this.AmoutMoney.ReadOnly = true;
            this.Amount.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.Amount.DataPropertyName = "Amount";
            this.Amount.FillWeight = 90f;
            this.Amount.HeaderText = "数量";
            this.Amount.Name = "Amount";
            this.Amount.ReadOnly = true;
            this.AllMoneys.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.AllMoneys.HeaderText = "总价";
            this.AllMoneys.Name = "AllMoneys";
            this.AllMoneys.ReadOnly = true;
            this.AmountUnit.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.AmountUnit.DataPropertyName = "AmountUnit";
            style9.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.AmountUnit.DefaultCellStyle = style9;
            this.AmountUnit.FillWeight = 90f;
            this.AmountUnit.HeaderText = "单位";
            this.AmountUnit.Name = "AmountUnit";
            this.AmountUnit.ReadOnly = true;
            this.Remark.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.Remark.DataPropertyName = "Remark";
            style10.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style10.BackColor = Color.White;
            this.Remark.DefaultCellStyle = style10;
            this.Remark.FillWeight = 150f;
            this.Remark.HeaderText = "商品规格";
            this.Remark.Name = "Remark";
            this.Remark.ReadOnly = true;
            this.IsZs.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.IsZs.HeaderText = "赠送";
            this.IsZs.Name = "IsZs";
            this.IsZs.ReadOnly = true;
            this.IsZs.Resizable = DataGridViewTriState.True;
            this.IsZs.SortMode = DataGridViewColumnSortMode.NotSortable;
            this.panel_Title.Controls.Add(this.panel2);
            this.panel_Title.Controls.Add(this.panel1);
            this.panel_Title.Controls.Add(this.lbl_Titles);
            this.panel_Title.Controls.Add(this.lbl_PrintTel);
            this.panel_Title.Controls.Add(this.lbl_PrintAddress);
            this.panel_Title.Controls.Add(this.lbl_PrintTiltes);
            this.panel_Title.Dock = DockStyle.Top;
            this.panel_Title.Location = new Point(0, 0);
            this.panel_Title.Name = "panel_Title";
            this.panel_Title.Size = new Size(0x2ec, 0xa3);
            this.panel_Title.TabIndex = 10;
            this.panel2.Controls.Add(this.lbl_NoNum);
            this.panel2.Dock = DockStyle.Bottom;
            this.panel2.Location = new Point(0, 0x72);
            this.panel2.Name = "panel2";
            this.panel2.Size = new Size(0x2ec, 0x17);
            this.panel2.TabIndex = 5;
            this.lbl_NoNum.AutoSize = true;
            this.lbl_NoNum.Location = new Point(600, 5);
            this.lbl_NoNum.Name = "lbl_NoNum";
            this.lbl_NoNum.Size = new Size(0x3b, 12);
            this.lbl_NoNum.TabIndex = 0;
            this.lbl_NoNum.Text = "lbl_NoNum";
            this.panel1.Controls.Add(this.lbl_GuestName);
            this.panel1.Controls.Add(this.lbl_DateTime);
            this.panel1.Dock = DockStyle.Bottom;
            this.panel1.Location = new Point(0, 0x89);
            this.panel1.Name = "panel1";
            this.panel1.Size = new Size(0x2ec, 0x1a);
            this.panel1.TabIndex = 4;
            this.lbl_GuestName.AutoSize = true;
            this.lbl_GuestName.Location = new Point(4, 6);
            this.lbl_GuestName.Name = "lbl_GuestName";
            this.lbl_GuestName.Size = new Size(0x53, 12);
            this.lbl_GuestName.TabIndex = 1;
            this.lbl_GuestName.Text = "lbl_GuestName";
            this.lbl_DateTime.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.lbl_DateTime.AutoSize = true;
            this.lbl_DateTime.Location = new Point(0x25b, 6);
            this.lbl_DateTime.Name = "lbl_DateTime";
            this.lbl_DateTime.Size = new Size(0x4d, 12);
            this.lbl_DateTime.TabIndex = 0;
            this.lbl_DateTime.Text = "lbl_DateTime";
            this.lbl_Titles.AutoSize = true;
            this.lbl_Titles.Font = new Font("宋体", 15.75f, FontStyle.Bold);
            this.lbl_Titles.Location = new Point(0x149, 0x55);
            this.lbl_Titles.Name = "lbl_Titles";
            this.lbl_Titles.Size = new Size(90, 0x15);
            this.lbl_Titles.TabIndex = 3;
            this.lbl_Titles.Text = "收   据";
            this.lbl_PrintTel.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.lbl_PrintTel.AutoSize = true;
            this.lbl_PrintTel.Font = new Font("宋体", 15f, FontStyle.Bold, GraphicsUnit.Point, 0x86);
            this.lbl_PrintTel.Location = new Point(0x130, 0x3b);
            this.lbl_PrintTel.Name = "lbl_PrintTel";
            this.lbl_PrintTel.Size = new Size(0x8d, 20);
            this.lbl_PrintTel.TabIndex = 2;
            this.lbl_PrintTel.Text = "lbl_PrintTel";
            this.lbl_PrintAddress.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.lbl_PrintAddress.AutoSize = true;
            this.lbl_PrintAddress.Font = new Font("宋体", 15f, FontStyle.Bold, GraphicsUnit.Point, 0x86);
            this.lbl_PrintAddress.Location = new Point(0x11a, 0x21);
            this.lbl_PrintAddress.Name = "lbl_PrintAddress";
            this.lbl_PrintAddress.Size = new Size(0xb9, 20);
            this.lbl_PrintAddress.TabIndex = 1;
            this.lbl_PrintAddress.Text = "lbl_PrintAddress";
            this.lbl_PrintTiltes.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.lbl_PrintTiltes.AutoSize = true;
            this.lbl_PrintTiltes.Font = new Font("宋体", 18f, FontStyle.Bold, GraphicsUnit.Point, 0x86);
            this.lbl_PrintTiltes.Location = new Point(0x110, 5);
            this.lbl_PrintTiltes.Name = "lbl_PrintTiltes";
            this.lbl_PrintTiltes.Size = new Size(0xcd, 0x18);
            this.lbl_PrintTiltes.TabIndex = 0;
            this.lbl_PrintTiltes.Text = "lbl_PrintTiltes";
            this.panel9.Dock = DockStyle.Bottom;
            this.panel9.Location = new Point(0, 0x1ac);
            this.panel9.Name = "panel9";
            this.panel9.Size = new Size(0x2ec, 5);
            this.panel9.TabIndex = 3;
            this.pan_Rights.Dock = DockStyle.Right;
            this.pan_Rights.Location = new Point(0x2f6, 10);
            this.pan_Rights.Name = "pan_Rights";
            this.pan_Rights.Size = new Size(10, 0x1d8);
            this.pan_Rights.TabIndex = 3;
            this.pan_Lefts.Dock = DockStyle.Left;
            this.pan_Lefts.Location = new Point(0, 10);
            this.pan_Lefts.Name = "pan_Lefts";
            this.pan_Lefts.Size = new Size(10, 0x1d8);
            this.pan_Lefts.TabIndex = 2;
            this.pan_Bottoms.Dock = DockStyle.Bottom;
            this.pan_Bottoms.Location = new Point(0, 0x1e2);
            this.pan_Bottoms.Name = "pan_Bottoms";
            this.pan_Bottoms.Size = new Size(0x300, 10);
            this.pan_Bottoms.TabIndex = 1;
            this.pane_TopT.Dock = DockStyle.Top;
            this.pane_TopT.Location = new Point(0, 0);
            this.pane_TopT.Name = "pane_TopT";
            this.pane_TopT.Size = new Size(0x300, 10);
            this.pane_TopT.TabIndex = 0;
            this.pan_DockBottom.BackColor = Color.FromArgb(0xaf, 0xbf, 190);
            this.pan_DockBottom.Dock = DockStyle.Bottom;
            this.pan_DockBottom.Location = new Point(1, 0x1ec);
            this.pan_DockBottom.Name = "pan_DockBottom";
            this.pan_DockBottom.Size = new Size(0x300, 1);
            this.pan_DockBottom.TabIndex = 2;
            this.pan_DockRight.BackColor = Color.FromArgb(0xaf, 0xbf, 190);
            this.pan_DockRight.Dock = DockStyle.Right;
            this.pan_DockRight.Location = new Point(0x301, 0);
            this.pan_DockRight.Name = "pan_DockRight";
            this.pan_DockRight.Size = new Size(1, 0x1ed);
            this.pan_DockRight.TabIndex = 1;
            this.pan_Top.Controls.Add(this.pan_ZhongJian);
            this.pan_Top.Controls.Add(this.pan_TopRight);
            this.pan_Top.Controls.Add(this.pan_TopLeft);
            this.pan_Top.Dock = DockStyle.Top;
            this.pan_Top.Location = new Point(0, 0);
            this.pan_Top.Name = "pan_Top";
            this.pan_Top.Size = new Size(770, 0x20);
            this.pan_Top.TabIndex = 4;
            this.pan_ZhongJian.BackgroundImage = Resources.uc_title_2;
            this.pan_ZhongJian.Controls.Add(this.lblTitle);
            this.pan_ZhongJian.Dock = DockStyle.Fill;
            this.pan_ZhongJian.Location = new Point(0x1f, 0);
            this.pan_ZhongJian.Name = "pan_ZhongJian";
            this.pan_ZhongJian.Size = new Size(0x2de, 0x20);
            this.pan_ZhongJian.TabIndex = 2;
            this.pan_ZhongJian.MouseDown += new MouseEventHandler(this.pan_ZhongJian_MouseDown);
            this.lblTitle.AutoSize = true;
            this.lblTitle.BackColor = Color.FromArgb(0, 0, 15, 0xff);
            this.lblTitle.Font = new Font("宋体", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0x86);
            this.lblTitle.ForeColor = Color.FromArgb(0x3b, 0x56, 20);
            this.lblTitle.Location = new Point(6, 8);
            this.lblTitle.Name = "lblTitle";
            this.lblTitle.Size = new Size(0x5b, 13);
            this.lblTitle.TabIndex = 0;
            this.lblTitle.Text = "打印销售单据";
            this.pan_TopRight.BackgroundImage = Resources.uc_title_1;
            this.pan_TopRight.Dock = DockStyle.Right;
            this.pan_TopRight.Location = new Point(0x2fd, 0);
            this.pan_TopRight.Name = "pan_TopRight";
            this.pan_TopRight.Size = new Size(5, 0x20);
            this.pan_TopRight.TabIndex = 1;
            this.pan_TopLeft.BackgroundImage = Resources.uc_title;
            this.pan_TopLeft.Dock = DockStyle.Left;
            this.pan_TopLeft.Location = new Point(0, 0);
            this.pan_TopLeft.Name = "pan_TopLeft";
            this.pan_TopLeft.Size = new Size(0x1f, 0x20);
            this.pan_TopLeft.TabIndex = 0;
            this.pan_TopLeft.MouseDown += new MouseEventHandler(this.pan_TopLeft_MouseDown);
            this.MyPrintDocument.PrintPage += new PrintPageEventHandler(this.MyPrintDocument_PrintPage);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(770, 0x20d);
            base.Controls.Add(this.pan_Dock);
            base.Controls.Add(this.pan_Top);
            base.FormBorderStyle = FormBorderStyle.None;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "FrmOrdersPrint";
            base.ShowInTaskbar = false;
            base.Load += new EventHandler(this.FrmOrdersPrint_Load);
            this.pan_Dock.ResumeLayout(false);
            this.pan_AllPanel.ResumeLayout(false);
            this.panel_Button.ResumeLayout(false);
            this.pan_AllPlanes.ResumeLayout(false);
            this.panel4.ResumeLayout(false);
            this.panel4.PerformLayout();
            this.panel3.ResumeLayout(false);
            this.panel6.ResumeLayout(false);
            this.panel6.PerformLayout();
            this.panel5.ResumeLayout(false);
            this.panel7.ResumeLayout(false);
            this.panel10.ResumeLayout(false);
            this.panel10.PerformLayout();
            this.panel8.ResumeLayout(false);
            this.panel8.PerformLayout();
            ((ISupportInitialize) this.DataGridList).EndInit();
            this.panel_Title.ResumeLayout(false);
            this.panel_Title.PerformLayout();
            this.panel2.ResumeLayout(false);
            this.panel2.PerformLayout();
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            this.pan_Top.ResumeLayout(false);
            this.pan_ZhongJian.ResumeLayout(false);
            this.pan_ZhongJian.PerformLayout();
            base.ResumeLayout(false);
        }

        private void LoadSalesDeticl(int orderId)
        {
            int num;
            Exception exception;
            DataTable list = OrdersCommBll.GetList("OrdersId=" + orderId);
            foreach (DataRow row in list.Rows)
            {
                CommEnt model = CommBll.GetModel(int.Parse(row["CommId"].ToString()));
                CommTypeEnt ent2 = null;
                if (model != null)
                {
                    ent2 = CommTypeBll.GetModel(model.CommTypeId);
                }
                this.DataGridList.Rows.Add();
                this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[1].Value = row["LotNum"].ToString();
                if (ent2 != null)
                {
                    this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[2].Value = ent2.CommTypeName;
                }
                if (model != null)
                {
                    this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[3].Value = model.CommName;
                }
                this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[4].Value = decimal.Parse(row["StandardMoney"].ToString()).ToString("F2");
                this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[5].Value = row["Discount"].ToString();
                this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[6].Value = decimal.Parse(row["AmoutMoney"].ToString()).ToString("F2");
                this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[7].Value = decimal.Parse(row["Amount"].ToString()).ToString("F2");
                this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[8].Value = decimal.Parse(row["AmoutMoney"].ToString()) * decimal.Parse(row["Amount"].ToString());
                ParameterEnt ent3 = ParameterBll.GetModel(int.Parse(row["AmoutUnit"].ToString()));
                if (ent3 != null)
                {
                    this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[9].Value = ent3.ParName;
                }
                this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[10].Value = row["Remark"].ToString();
                if (row["IsGiveGuestPresent"].ToString() == "1")
                {
                    this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[11].Value = "√";
                }
                else
                {
                    this.DataGridList.Rows[this.DataGridList.Rows.Count - 1].Cells[11].Value = "";
                }
            }
            if (this.DataGridList.Rows.Count < 9)
            {
                for (num = this.DataGridList.Rows.Count; num < 9; num++)
                {
                    this.DataGridList.Rows.Add();
                }
            }
            decimal num2 = 0M;
            try
            {
                for (num = 0; num < (this.DataGridList.Rows.Count - 1); num++)
                {
                    try
                    {
                        if (this.DataGridList.Rows[num].Cells[11].Value.ToString() != "√")
                        {
                            num2 += decimal.Parse(this.DataGridList.Rows[num].Cells[8].Value.ToString());
                        }
                    }
                    catch (Exception exception1)
                    {
                        exception = exception1;
                    }
                }
                this.lbl_AllMoney.Text = num2.ToString("F2");
                this.lbl_DaXie.Text = NumConversion.Format(double.Parse(num2.ToString("F2")));
            }
            catch (Exception exception2)
            {
                exception = exception2;
                this.lbl_AllMoney.Text = "0.00";
                this.lbl_DaXie.Text = "零";
            }
        }

        private void MyPrintDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            this.DataGridList.ClearSelection();
            e.Graphics.DrawImage(this.memoryImage, 0, 0);
        }

        private void pan_TopLeft_MouseDown(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(base.Handle, 0x112, 0xf012, 0);
        }

        private void pan_ZhongJian_MouseDown(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(base.Handle, 0x112, 0xf012, 0);
        }

        private void panel_Button_Paint(object sender, PaintEventArgs e)
        {
            this.Panel_ResetPaint(e, this.panel_Button, Color.Black, 1, 1, 1, 1);
        }

        private void Panel_ResetPaint(PaintEventArgs e, Panel panel, Color color, int leftBoder, int topBoder, int rightBoder, int bottomBoder)
        {
            ControlPaint.DrawBorder(e.Graphics, panel.ClientRectangle, color, leftBoder, ButtonBorderStyle.Solid, color, topBoder, ButtonBorderStyle.Solid, color, rightBoder, ButtonBorderStyle.Solid, color, bottomBoder, ButtonBorderStyle.Solid);
        }

        private void panel10_Paint(object sender, PaintEventArgs e)
        {
            this.Panel_ResetPaint(e, this.panel10, Color.Black, 1, 1, 1, 1);
        }

        private void panel8_Paint(object sender, PaintEventArgs e)
        {
            this.Panel_ResetPaint(e, this.panel8, Color.Black, 0, 1, 1, 1);
        }

        [DllImport("user32.dll")]
        public static extern bool ReleaseCapture();
        [DllImport("user32.dll")]
        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
        private bool SetupThePrinting()
        {
            PrintDialog dialog = new PrintDialog {
                AllowCurrentPage = false,
                AllowPrintToFile = false,
                AllowSelection = false,
                AllowSomePages = false,
                PrintToFile = false,
                ShowHelp = false,
                ShowNetwork = false
            };
            this.MyPrintDocument.DocumentName = "采购单";
            this.MyPrintDocument.PrinterSettings = dialog.PrinterSettings;
            this.MyPrintDocument.DefaultPageSettings = dialog.PrinterSettings.DefaultPageSettings;
            return true;
        }
    }
}

